﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Register : System.Web.UI.Page
{
    RestaurantBooking.UsersDataTable userDataTable= null;
    RestaurantBookingTableAdapters.UsersTableAdapter userAdapter = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        userDataTable = new RestaurantBooking.UsersDataTable();
        userAdapter = new RestaurantBookingTableAdapters.UsersTableAdapter();
        userAdapter.Fill(userDataTable);
    }

    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtUserName.Text = "";
        txtPassword.Text = "";
        txtName.Text = "";
        txtPhone.Text = "";
        txtCompany.Text = "";
        txtEmail.Text = "";
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            RestaurantBooking.UsersRow newRow = userDataTable.NewUsersRow();
            newRow.Username = txtUserName.Text;
            newRow.Password = txtPassword.Text;
            newRow.Name = txtName.Text;
            newRow.Company = txtCompany.Text;
            newRow.IsAdmin = false;
            newRow.Email = txtEmail.Text;
            newRow.Phone = txtPhone.Text;
            newRow.Activation = true;
            userDataTable.Rows.Add(newRow);
            userAdapter.Update(userDataTable);

            Response.Redirect("default.aspx");
        }
    }
    
}
